<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('快速出库')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-input-inline">发运编号</label>
                        <input type="text" class="layui-input" name="fybh" id="fybh" placeholder="发运编号" />

                    </div>
                    <div class="layui-inline">
                        <label class="layui-input-inline">订单类型</label>
                        <select lay-ignore="lay-ignore" class="fylx" name="fylx" style="width: 193px"></select>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-input-inline">货品编号</label>
                        <input type="text" class="layui-input" name="hpbh" id="hpbh" placeholder="货品编号" />
                    </div>
                    <div class="layui-inline">
                        <label class="layui-input-inline">货品名称</label>
                        <input type="text" class="layui-input" name="hpmc" id="hpmc" placeholder="货品名称" />
                    </div>
                    <div class="layui-inline">
                        <label class="layui-input-inline">省</label>
                        <input type="text" class="layui-input" name="sheng" id="sheng" placeholder="省" />
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #40AFFE">重置</button>
                    </div>
                    <div class="moreSearch" style="display: none">
                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="cjsj" name="cjsj" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">下发状态</label>
                            <select id="fyzt" name="fyzt" class="selector" lay-filter="aihao">
                                <option value="" >全部</option>
                                <option value="0">未下发</option>
                                <option value="1" >已下发</option>
                                <option value="2">已完成</option>
                            </select>
                        </div>
                    </div>
                    <input type="hidden" id="cjsj_start" name="cjsj_start">
                    <input type="hidden" id="cjsj_end" name="cjsj_end">

                    <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                </form>
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn{
        width:50px;
        height:20px;
        text-align:center;
        color:#fff;
        line-height:20px;
        background-color:#eee;
        position:relative;
        margin: 0 auto;
        cursor: pointer;
    }
    .moreBtn:before{
        content:'';
        display:block;
        width:35px;
        height:20px;
        position:absolute;
        transform:skewX(30deg);
        background:#eee;
        border-top-left-radius:8px;
        left:-20px;
        top:0;
    }
    .moreBtn:after{
        content:'';
        display:block;
        width:35px;
        height:20px;
        position:absolute;
        transform:skewX(-30deg);
        background:#eee;
        border-top-right-radius:8px;
        top:0;
        right:-20px;
    }
</style>
<script th:inline="javascript">
    $(function () {

        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        });
        $('.fylx').select2({
            ajax: {
                url: '/zxsswms/wmsshipmentorder/getPoLx',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        ddlx: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].id,text:data[i].ddlx});
                        }
                    }
                    console.log(arr);
                    // Tranforms the top-level key of the response object from 'items' to 'results'
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询字段',
            allowClear: true
        });
    });
    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                /*查看*/
                getEvent: function(data){
                    search(data);
                },

                /*新增*/
                addEvent: function (data) {
                    getDialog(data);
                },
                /*生成*/
                generateEvent: function (data) {
                    generateDialog(data);
                },
            }
        });
        //新增
        function getDialog(data){
            // 查询供应商编号
            $.ajax({
                url: '/zxsswms/wmsshipmentorder/getBh',
                type: 'GET',
                dataType: 'json',
                contentType: "application/json",
                async: false,
                data: '',
                success:function(data){
                    var zzpUtils = layui.zzpUtils,
                        $ = layui.jquery,
                        laydate = layui.laydate;
                    zzpUtils.dialog({
                        title: "新增快速出库",
                        type: 2,
                        content: "/outOperation/addKsck?bh="+data.bh,
                        area: ['80%', '90%'], //设置dialog大小，也可以不设置，
                        end: function () {//增加成功后刷新
                            zzpUtils.refreshTable("#table");
                        }
                    });

                }
            });

        }
        //查看
        function  search(data) {
            var id=data.row.id;
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "查看明细",
                type: 2,
                content: "/outOperation/seachMx?id=" + id,
                area: ['80%', '80%'], //设置dialog大小，也可以不设置，
            });
        }
        //生成
        function generateDialog(data){
            var id=data.row.id;
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "查看拣货任务人员",
                type: 2,
                content: "/outOperation/creatKsck?id=" + id,
                area: ['50%', '35%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
        //处理时间
        laydate.render({
            elem: '#cjsj',
            type: 'date',
            range: '~',
            done: function(value, date, endDate){
                if(value!=null && value!=""){
                    var start=value.toString().substring(0,value.toString().indexOf("~"));
                    var end=value.toString().substring(value.toString().indexOf("~")+1);
                    $("#cjsj_start").val(Date.parse(new Date(start)));
                    $("#cjsj_end").val(Date.parse(new Date(end)));
                }else {
                    $("#cjsj_start").val("");
                    $("#cjsj_end").val("");
                }

                console.log(value); //得到日期生成的值，如：2017-08-18
                console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
            }
        });
        //加载表格
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: true,
            pagination: true,
            url: '/wmsquickexit/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'fybh',
                title: '发运编号'
            },{
                field: 'show_fylx',
                title: '发运类型'
            },{
                field: 'yxj',
                title: '优先级'
            },{
                field: 'show_fyzt',
                title: '下发状态',
            },{
                field: 'cjsj',
                title: '创建时间'
            },{
                field: 'sheng',
                title: '省'
            },{
                field: 'lxrxm',
                title: '联系人姓名'
            },{
                field: 'lxrdh',
                title: '联系人电话'
            }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter
        });
        //查询条件
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        });
        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            var button="";
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var item = functions.tableBtn[i];
                var btn = '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';
                if (row.fyzt == '0') {
                    button += btn;
                }else{
                    if (functions.tableBtn[i].name == '查看') {
                        button += btn;
                    }else{
                        button+='<button class="layui-btn layui-btn-xs layui-btn-disabled" disabled lay-event="' + item.event + '">'
                            + item.name
                            + '</button>';
                    }

                }
            }
            return button;
        }
    });
</script>
</html>